#ifndef  __CHUNK__
#define  __CHUNK__

#include "common.h"

/*@brief:
 *@para:FILE *fp:文件流;
 *	    char *FileName:上传文件的名称;
 *	    bytesWritten: 记录文件字节数;
 */
struct fileWriterData{
	FILE *fp;
	char *FileName;
	size_t bytesWritten;
};

/*
 *@HTTP multipart part; 
 */
struct httpMultiPart{
	char *fileName;
	char *varName;
	struct dynString data;
	int status;
	void *userData;
};


/*
 *@上传状态;
 */
enum MULTIPART_STATE{
	MULTIPART_HTTP_BEGIN = 0x01,
	MULTIPART_HTTP_DATA,
	MULTIPART_HTTP_END, 
};


int httpMultiPartWaitForBoundary(struct connection *conn);


int httpMultiPartProcessBoundary(struct connection *conn);


int httpUpload(struct connection *conn, int state, struct httpMultiPart *part);


int httpMultiPartContinueWaitForChunk(struct connection *conn);


int httpMultiPartGotChunk(struct connection *conn);


int httpMultiPartFinalize(struct connection *conn);


int httpMultipartBegin(struct connection *conn, struct httpMessage *hm, int requestLen);


int httpMultipartContinue(struct connection *conn);



#endif
